package com.huike.business.service.impl;

import com.huike.business.domain.TbBizTrackRecord;
import com.huike.business.domain.TbBusiness;
import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.domain.dto.BizRecordDTO;
import com.huike.business.domain.vo.BizRecordVO;
import com.huike.business.mapper.TbBusinessMapper;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessService;
import com.huike.business.service.TbBusinessTrackRecordService;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import com.huike.common.utils.uuid.UUIDUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TbBusinessTrackRecordServiceimpl implements TbBusinessTrackRecordService {
    @Autowired
    private TbBusinessTrackRecordMapper tbBusinessTrackRecordMapper;
        @Autowired
        private TbBusinessMapper tbBusinessMapper;

    @Override
    public void getbusinessRecord( BizRecordDTO bizRecordDTO) {
        TbBusiness tbBusiness = new TbBusiness();
        BeanUtils.copyProperties(bizRecordDTO,tbBusiness);
        tbBusiness.setId(bizRecordDTO.getBusinessId());
        tbBusinessMapper.updateTbBusiness(tbBusiness);

        TbBizTrackRecord trackRecord = new TbBizTrackRecord();
        BeanUtils.copyProperties(bizRecordDTO,trackRecord);
        trackRecord.setCreateTime(DateUtils.getNowDate());
        trackRecord.setCreateBy(SecurityUtils.getUsername());
        tbBusinessTrackRecordMapper.getbusinessRecord(trackRecord);
    }

    @Override
    public List<BizRecordVO> getTbBusinessTrackRecords(Long businessId) {
        List<BizRecordVO> tbBusiness=tbBusinessTrackRecordMapper.getTbBusinessTrackRecords(businessId);
        return tbBusiness;
    }
}
